﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Bidder_DrugsviewsUpdate : System.Web.UI.Page
{
    public string strName1, strContent1;
    public string InfoId;
    protected void Page_Load(object sender, EventArgs e)
    {
        string strName, strContent;
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCompany);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {
            HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
            if (Request.QueryString["Id"] != null)
                InfoId = SysFun.IsSQL(Request.QueryString["Id"].ToString());
            else
                return;

            if (!IsPostBack)
            {
                string strSql;
                strSql = "select * from Drugsviews where AccountId=" + _Account.AccountId.ToString() + " and Id=" + InfoId;
                Db DbInfo = new Db();
                System.Data.IDataReader dr;
                dr = DbInfo.DataReader(strSql);
                if (dr.Read())
                {
                    strName1 = dr["Title"].ToString();
                    strContent1 = dr["Content"].ToString();

                }
                dr.Close();
                dr.Dispose();
                DbInfo.Close();
            }
            strName = SysFun.ToTrim(Request.Form["txtName"]);
            strContent = SysFun.ToTrim(Request.Form["txtContentHtml"]);
            if (strName != "" && strContent != "")
            {
                HZ.MBSM.Model.Drugsviews Drugsviews = new HZ.MBSM.Model.Drugsviews();
                Drugsviews.Title = strName;
                Drugsviews.Content = strContent.Replace("\r\n", "");
                Drugsviews.AccountId = _Account.AccountId;
                Drugsviews.ID = SysFun.ToInt(InfoId);
                HZ.MBSM.BLL.Drugsviews DrugsviewsOperator = new HZ.MBSM.BLL.Drugsviews();
                if (DrugsviewsOperator.Update(Drugsviews))
                {
                    HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "修改", "Drugsviews", Drugsviews.ID.ToString() + Drugsviews.AccountId.ToString() + "|" + Drugsviews.Content + "|" + Drugsviews.CreateDate, "../Bidder/DrugsviewsAdd.aspx");
                    Response.Write("<script>alert('保存成功！！！');window.opener.location.reload();window.close();</script>");
                }
                else
                {
                    Response.Write("<script>alert('保存失败！！！');</script>");
                }
            }
        }
    }
}
